import os

from deleteFolderContents import deleteFolderContents
from openFile import openFile


def startCleaning():
    # 防止用户误删文件
    canCleaned = [r'C:\\Windows\\temp', r'C:\\Temp', r'C:\\Users\\.*\\AppData\\Local\\Temp',
                  r'C:\\Windows\\WinSxS\\Backup', r'C:\\Windows\\Help', r'C:\\Windows\\Prefetch',
                  r'C:\\Windows\\ServiceProfiles\\LocalService\\AppData\\Local\\Temp',
                  r'C:\\Windows\\SoftwareDistribution\\Download']
    needCleaned_list = openFile()
    # 去除注释和无效路径
    needCleaned_list = [folder for folder in needCleaned_list if not folder.startswith('#') and os.path.exists(folder)]
    for needCleaned in needCleaned_list:
        print(needCleaned + '开始清理。。。')
        deleteFolderContents(folder_path=needCleaned)
        print('清理完成')